//
//  BaseNormalTableView.m
//  DDKelai
//
//  Created by Admin on 16/1/21.
//  Copyright © 2016年 Admin. All rights reserved.
//

#import "BaseNormalTableView.h"

static NSString *cellIdentifier = @"baseCell";

@interface BaseNormalTableView ()

@end

@implementation BaseNormalTableView

- (void)_init
{
    self.dataSource = self;
    self.delegate = self;
    self.backgroundColor = [UIColor clearColor];
    self.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier];
}

- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
{
    self = [super initWithFrame:frame style:style];
    
    if (self) {
        
        [self _init];
    }
    
    return self;
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    [self _init];
}

#pragma mark - TableView Datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.data count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [self dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
    if ([self.data[indexPath.row] isKindOfClass:[NSString class]]) {
        cell.textLabel.text = self.data[indexPath.row];
    }
    
    return cell;
}

#pragma mark - TableView Delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
    if (self.didSelectedRow != nil) {
        self.didSelectedRow(tableView, indexPath);
    }
}

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{

    
}

#pragma mark - UIScrollViewDelegate
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    if (self.beginScroll) {
        self.beginScroll(self);
    }
}


@end
